<template>
	<view>
		<view class="P_3 flex_row_between">
			
			<view class="flex_colC">
				<view @click="tabClick(0)" class="PTB_3 flex_colC bg_fff B_radius_5 W_44vw">
					<view class="font_weight_bold fontS_18" style="display: flex;align-items: flex-end;">
						<view class="font_weight_bold fontS_16">
							{{Number(info.selfTotalBonus).toFixed(2)}}
						</view>
						<view class="fontS_10 PL_1">
							KSA
						</view>
					</view>
					<view class="PT_1">
						今日个人奖励
					</view>
				</view>
				
				<view :class="idx==0?'bg_gold':''" class="W_20vw  MT_2" style="height: 2px;">
					
				</view>
			</view>
			
			<view @click="tabClick(1)" class="flex_colC">
				<view class="PTB_3 flex_colC bg_fff B_radius_5 W_44vw">
					<view class="font_weight_bold fontS_18" style="display: flex;align-items: flex-end;">
						<view class="font_weight_bold fontS_16">
							{{Number(info.teamTotalBonus).toFixed(2)}}
						</view>
						<view class="fontS_10 PL_1">
							KSA
						</view>
					</view>
					<view class="PT_1">
						今日社区奖励
					</view>
				</view>
				
				<view :class="idx==1?'bg_gold':''" class="W_20vw MT_2" style="height: 2px;">
					
				</view>
			</view>
			
		</view>
		
		<view v-if="idx==0" class="PTB_3 bg_fff MLR_3 B_radius_5 flex_row_between">
			<view style="width: 50%;" class="flex_rowC">
				今日撮合总量：{{Number(info.selfTotalActionMoney).toFixed(2)}}
			</view>
			<view class="H_6vw bg_000" style="width: 1px;">
				
			</view>
			<view style="width: 50%;" class="flex_rowC">
				今日总奖励：{{Number(info.teamTotalActionMoney).toFixed(2)}}
			</view>
		</view>
		
		<view class="bg_fff P_2 MT_3" v-if="idx==0">
			<view class="font_weight_bold P_2 line_bom">
				撮合记录
			</view>
			<view @click="uOpenWin('../heyue/zhuDet?info='+JSON.stringify(item))" class="PTB_2 PLR_2 line_bom" v-for="(item,i) in cangList" :key='i'>
				<view class="flex_row_between">
					<view
							:class="item.action_code==1?'color_up':'color_down'"
							 class="font_weight_bold fontS_16 flex_rowL"
						>
							<view >
								{{item.action_code==1?'撮涨':'撮跌'}}
							</view>
							<view class="PL_1 pub_color">
								{{Number(item.action_money).toFixed(2)}}
							</view>
							<view class="fontS_10 pub_color PR_1" style="padding-top: 0.8vw;">
								KSA
							</view>
							<view class="">
								{{item.status_text}}
							</view>
						</view>
						
						
						<view 
						:class="item.action_code==1?'color_up':'color_down'"
						class="font_weight_bold fontS_16 flex_rowL">
							{{item.bonus}}
							<view class="fontS_10 pub_color PR_1" style="padding-top: 0.8vw;">
								KSA
							</view>
						</view>
					<!-- </view> -->
				</view>
				
				<view class="flex_row_between color_gray">
					<view class="fontS_10 color_gray">
						{{item.issue && Number(item.issue.start_price).toFixed(2)}}
						-
						{{item.issue && Number(item.issue.end_price).toFixed(2)}}
					</view>
					<view class="font_weight_bold">
						币种：{{item.base_currency.toUpperCase()}}
					</view>
				</view>
				<view class="flex_row_between color_gray">
					<view class="fontS_10 color_gray">
						{{item.start_time}}
					</view>
					<view class="fontS_10">
						{{item.end_time}}
					</view>
				</view>
			</view>
		</view>
		
		<view class="bg_fff P_2" v-if="idx==1">
			<view class="flex_row_between line_bom PTB_2">
				<view class="w_l33 flex_rowC">
					姓名(直推)
				</view>
				<view class="w_l33 flex_rowC">
					今日总撮合
				</view>
				<view class="w_l33 flex_rowC">
					今日奖励
				</view>
			</view>
			<view class="PTB_3 flex_row_between line_bom" v-for="(item,i) in cangList" :key='i'>
				<view class="w_l33 flex_rowC">
					<view class="PL_1 color_gold vip flex_rowC">
						lv.{{item.level}}
					</view>
					<view class="">
						{{item.mobile}}
					</view>
					
				</view>
				<view class="w_l33 flex_rowC">
					{{item.totalActionMoney}}
				</view>
				<view class="w_l33 flex_rowC">
					{{item.totalBonus}}
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:{},
				idx:0,
				cangList:[],
				page:1,
				showText:'',
				state:true,
				list:[]
			}
		},
		onLoad() {
			this.getInfo();
			this.getList();
		},
		onReachBottom() {
			if (this.state) {
				this.showTxt = '加载中...';
				this.page++
				this.getList();
			}
		},
		onPullDownRefresh() {
			//this.getSorts();
			// this.getInfo()
			this.getList();
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			getList(){
				let _this = this;
				let url = ''
				if(this.idx==0){
					url = 'bet/index'
				}else{
					url = 'user/childReward'
				};
				this.$req(url,{page:_this.page},(res)=>{
					if(res.code==1){
						if(res.data.list && res.data.list.length>0){
							if(_this.page==1){
								_this.cangList = res.data.list;
							}else{
								_this.cangList = _this.cangList.concat(res.data.list)
							}
						}else{
							_this.showText = '没有更多了';
							_this.state = false;
						}
					}else{
						_this.toast(res.msg)
					}
				})
			},
			tabClick(i){
				this.idx = i;
				this.getList();
			},
			getInfo(){
				let _this = this;
				this.$req('user/reward',{},function(res){
					_this.info = res.data;
				})
			}
		}
	}
</script>

<style>
.w_l33{
	width: 33%;
}
.vip{
	background-image: url(../../static/vip.png);
	background-size: 100% 100%;
	background-repeat: no-repeat;
	padding: 0.1vw 1vw;
}
</style>
